//
//  ZYBConfigInfo.h
//  homework
//
//  Created by gaofeng on 15/11/27.
//  Copyright © 2015年 zyb. All rights reserved.
//

#ifndef ZYBConfigInfo_h
#define ZYBConfigInfo_h

#pragma mark - screen

#define kScreenHeight                       [[UIScreen mainScreen] bounds].size.height
#define kScreenWidth                        [[UIScreen mainScreen] bounds].size.width
//适配iPhoneX
#define DeviceIsIphoneX                     ((MIN(kScreenWidth,kScreenHeight) == 375 && MAX(kScreenWidth,kScreenHeight) == 812)?YES:NO)
#define kZDNavigationBarHeight              44
#define kZDNaviagtionBarFontSize            19
#define kZDStatusBarHeight                  (DeviceIsIphoneX?44:20)
#define kZDTabBarHeight                     (DeviceIsIphoneX?(49+34):49)
#define kZDBottomSpace                      (DeviceIsIphoneX?34:0)
#define kAdaptedWidth4(width)               (width * (kScreenWidth / 320))
#define kAdaptedWidth47(width)              (width * (kScreenWidth / 375))

#define kZDValuationTimes  5

#define kNavigationBarBottom  (kZDStatusBarHeight + kZDNavigationBarHeight)

#define kContentHeight kScreenHeight - (kNavigationBarBottom) - 34   //特殊界面  张燕燕

#define DeviceIsPad       (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define DeviceIsPhone     (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

#define IOS_2_0 @"2.0"
#define IOS_3_0 @"3.0"
#define IOS_4_0 @"4.0"
#define IOS_5_0 @"5.0"
#define IOS_6_0 @"6.0"
#define IOS_7_0 @"7.0"
#define IOS_8_0 @"8.0"
#define IOS_9_0 @"9.0"
#define IOS_10_0 @"10.0"
#define IOS_11_0 @"11.0"

#define ReplaceNaN(number) (number = isnan(number) ? MAXFLOAT : number)
#define ReplaceNaNWithNumber(number,withNumber) (number = isnan(number) ? withNumber : number)

#define NumberInRange(number, min, max) MAX(MIN(max, number), min)

#define NumberToNumberIfNotFound(x, placeholder) (x == NSNotFound ? placeholder : x)
#define NumberToZeroIfNotFound(x) (x == NSNotFound ? 0 : x)

#define kSafeBlock(block, ...)                      (!block ?: block(__VA_ARGS__))

#define kSafePerformSelector(target, sel, ...) if ([target respondsToSelector:sel]) {\
[target performSelectorWithArgs:sel, __VA_ARGS__];\
}\

// 去除Warc-performSelector-leaks警告
#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)

// 去除Wundeclared-selector警告
#define SuppressSelectorDeclaredWarning(Stuff) \
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wundeclared-selector\"") \
Stuff; \
_Pragma("clang diagnostic pop") \
} while (0)

#pragma mark - System Version
#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)

#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)

#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)

#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)

#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

#pragma mark - common const

#define ZD_APP_DELEGATE ((ZDAppDelegate *)[UIApplication sharedApplication].delegate)

#define DEVICE_IS_IPHONE  [[UIDevice currentDevice].model isEqualToString:@"iPhone"]

// 展示层级定义
#define ZDDisplayLevel_SelectView   (UIWindowLevelAlert-1)      //截屏反馈层级
#define ZDDisplayLevel_AlertTost    (UIWindowLevelAlert+1)      //提示和弹框层级

#define UserAvatar000000000000 @"UserAvatar000000000000.png"

#endif /* ZYBConfigInfo_h */

